package com.bitdf.txing.group.feign.impl.product;

import com.bitdf.txing.common.to.SkuReductionTo;
import com.bitdf.txing.common.utils.R;
import com.bitdf.txing.product.feign.ProductSeckillFeginService;
import com.bitdf.txing.seckill.dao.SeckillSessionDao;
import com.bitdf.txing.seckill.service.SeckillService;
import com.bitdf.txing.seckill.service.SkuFullReductionService;
import com.bitdf.txing.seckill.to.SeckillSkuRedisTo;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
import org.springframework.stereotype.Service;

/**
 * @author Lizhiwei
 * @date 2023/9/6 19:27:58
 * 注释：
 */
@Service
@Slf4j
@ConditionalOnProperty(value = "tx.deploy.mode", havingValue = "standalone")
public class ProductSeckillFeginServiceImpl implements ProductSeckillFeginService {
    @Autowired
    SeckillService seckillService;
    @Autowired
    SkuFullReductionService skuFullReductionService;

    @Override
    public R getSkuSeckillInfo(Long skuId) {
        SeckillSkuRedisTo to = seckillService.getSkuSeckilInfo(skuId);
        return R.ok().setData(to);
    }

    @Override
    public R saveSkuReduction(SkuReductionTo skuReductionTo) {
        skuFullReductionService.saveSkuReduction(skuReductionTo);
        log.info("满减信息保存成功");
        return R.ok();
    }
}
